package com.symaster.common.swing.style;

import com.symaster.common.swing.config.AppConfig;
import com.symaster.common.swing.style.border.RoundBorder;

import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.plaf.BorderUIResource;
import java.awt.*;

/**
 * @author yinmiao
 * @date 2021-08-18 08:50
 */
public class Style {

    public static final int BORDER_EMPTY = 1;
    public static final int ROUND_BORDER = 2;
    public static final int SANS_SERIF_12 = 1;
    /**
     * 无边框
     */
    private static final Border border1 = new BorderUIResource.BevelBorderUIResource(2);
    private static final Border border2 = new RoundBorder(AppConfig.getColor("high_gloss_color"));
    /**
     * 全部默认主字体
     */
    private static final Font font = new Font("Microsoft YaHei UI", Font.PLAIN, 12);

    public static void setBorder(int type, JComponent... com) {
        switch (type) {
            case (BORDER_EMPTY):
                for (JComponent item : com) item.setBorder(border1);
                break;
            case (ROUND_BORDER):
                for (JComponent item : com) item.setBorder(border2);
                break;
            default:
                for (JComponent item : com) item.setBorder(border1);
                break;
        }
    }

    public static void setFont(int type, Component... com) {
        if (type == SANS_SERIF_12) {
            for (Component item : com) item.setFont(font);
        } else {
            for (Component item : com) item.setFont(font);
        }
    }

    public static Font getFont(int type) {
        if (type == SANS_SERIF_12) {
            return font;
        }
        return font;
    }
}
